﻿using UnityEngine;
using System.Collections;

public class Bullet : MonoBehaviour 
{	
	public float velocity;
	//public int gameObject;

	void Awake()
	{
		Destroy(this.gameObject, 3);	
	}

	void Update()
	{
		transform.Translate(0, velocity * Time.deltaTime, 0);

	}

	void OnTriggerEnter2D(Collider2D coll)
	{
		if(coll.gameObject.tag == "black")
		{	//pege o componente da cs enemy_black e diminua o valor da variavel life
			coll.GetComponent<enemy_black>().life--;
			if(coll.GetComponent<enemy_black>().life <= 0)
			{
		    	Destroy(coll.gameObject);
			}
			Destroy(this.gameObject);
		}
	}
}